package mt;

import java.util.LinkedList;
import java.util.Scanner;

/**
 * @author zhangmin
 * @create 2022-03-17 20:25
 */
public class meituan2021_2_3 {
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int n=cin.nextInt();
        cin.nextLine();
        int cout=0;
        String lastfrom="";
        for (int i = 0; i < n; i++) {
            String line=cin.nextLine();
            String[] split = line.split(" ");
            String from= split[0],to=split[1];
            if (lastfrom.equals("")){
                lastfrom=from;
            }
            if(lastfrom.equals(to)){
                //完成一段旅程
                cout++;
                lastfrom="";
            }
        }
        System.out.println(cout);
    }
}
